import React, { Component } from "react";
import Proptypes from "prop-types";
console.log(Proptypes);
React.PropTypes = Proptypes;
import { AppRegistry } from "react-native";
import Application from "./App";
import { createStore, applyMiddleware, combineReducers } from "redux";
import {
  reduxifyNavigator,
  createReactNavigationReduxMiddleware,
  createNavigationReducer
} from "react-navigation-redux-helpers";
import { Provider, connect } from "react-redux";
import ReduxPromise from "redux-promise";
// 本地持久化
import SQLite from 'react-native-sqlite-storage';
import Login from "./src/components/pages/Login";

SQLite.DEBUG(true);
SQLite.enablePromise(true);


// 创建reducer
const navReducer = createNavigationReducer(Application);
const appReducer = combineReducers({
  nav: navReducer
  //   ...其他reducer
});

const middleware = [
  createReactNavigationReduxMiddleware("root", state => state.nav),
  ReduxPromise
];

const App = reduxifyNavigator(Application, "root");
const mapStateToProps = state => ({
  state: state.nav
});

const AppWithNavigationState = connect(mapStateToProps)(App);
const store = createStore(appReducer, applyMiddleware(...middleware));

class Root extends Component {
  render() {
    return (
      <Provider store={store}>
        <AppWithNavigationState />
      </Provider>
    );
  }
}

const offYellowBxoWarning = () => {
  // 忽略的警告
  console.ignoredYellowBox = [
    "Warning: BackAndroid is deprecated. Please use BackHandler instead.",
    "source.uri should not be an empty string",
    "Invalid props.style key"
  ];
  // 关闭全部黄色警告
  console.disableYellowBox = true;
};

offYellowBxoWarning();

AppRegistry.registerComponent("BgtApp", () => Root);
